<template>
	<view class="special-content">
		<view class="special-list">
			<view class="special-item" v-for="(item,index) in exerciseList" :key="item.id" @click="gotoPractice(item.id)">
				<view class="spec-title">{{item.name}}</view>
				<view class="spec-num">
					<!-- <view>{{item.num}}题</view> -->
					<u-icon name="arrow-right" color="#666666" size="28"></u-icon>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { getSpeciallist,topicDetails } from '../../api/index.js'
	export default{
		data(){
			return{
				exerciseList:[],
				currentTag:1
			}
		},
		mounted() {
			this.getSpeciallists()
		},
		onLoad(options) {
			this.currentTag = options.currentTag
		},
		methods:{
			// 跳转到练习
			gotoPractice(id){
				let that = this
				if (uni.getStorageSync('access_token') != '') {
					uni.navigateTo({
						url:'/pagesA/topicPractice/index?type=2&currentTag='+this.currentTag + '&id='+id
					})
				} else {
					uni.showModal({
						title: '提示',
						content: '您当前未登录，是否登录？',
						success: function (res) {
							if (res.confirm) {
								that.gotoLigin()
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
				}
			},
			// 获取list
			getSpeciallists(){
				let that = this
				getSpeciallist().then(res=>{
					// console.log(111,res.data);
					that.exerciseList = res.data.list;
					// let list = res.data.list;
					// list.map(item=>{
					// 	let num = that.getTopicDetails(item.id);
					// 	item['num'] = num;
					// })
				}).catch()
			},
			// 获取题目num
			getTopicDetails(id) {
				let num = 0;
				topicDetails(id).then(res=>{
					console.log(145,res.data);
					// num
				}).catch()
				return num
			}
		}
	}
</script>

<style lang="scss">
	.special-list{
		// padding: 20rpx;
		width: 95%;
		margin: 20rpx auto;
		background-color: #fff;
		
		.special-item{
			display: flex;
			justify-content: space-between;
			padding: 35rpx 0;
			width: 95%;
			margin: 0 auto;
			font-size: 28rpx;
			border-bottom: 1rpx solid #DFE0E6;
			
			.spec-title{
				color: #313233;
			}
			
			.spec-num{
				display: flex;
				align-items: center;
				color: #999999;
			}
		}
	}
</style>